from state import EditorState
from langchain_core.prompts import ChatPromptTemplate
from model.zhipu import get_model
from utils.tools import web_search_api

prompt = ChatPromptTemplate.from_template("""
基于{title}的标题查询资料信息
""")

model = get_model()


def search_resource(state: EditorState):
    title = state['title']
    paragraphs = state['paragraphs']

    data = web_search_api.invoke("中国近代史") # TODO 此处为假冒web_search

    print("============ Search Agent ============")
    print(data)

    return {
        "who": "",
        "title": title,  # 制定标题
        "search": data,  # 搜集信息
        "outlines": {},  # 大纲搜集信息 三级标题
        "paragraphs": paragraphs,  # 段落信息
        "check_idea": {},  # 校对意见
        "comment_idea": {}  # 评论意见
    }



# if __name__ == '__main__':
#     inputs = {
#         "who": "",
#         "title": "中国的近代历史",  # 制定标题
#         "search": "",  # 搜集信息
#         "outlines": {},  # 大纲搜集信息 三级标题
#         "paragraphs": [],  # 段落信息
#         "check_idea": {},  # 校对意见
#         "comment_idea": {}  # 评论意见
#     }
#
#     outputs = search_resource(inputs)
#     print(outputs)
#     print(outputs['title'])
